<template>
  <view class="doctor-con">
    <view class="doctor-list flexrow" v-for="(item, index) in MyDoctorList" :key="index"
      @click="todoctordetail(item.doctorId)">
      <view>
        <image :src="item.headImage
            ? baseUrl + item.headImage
            : 'https://applet.youtuyiliao.com/profile/upload/xiaochengxu/static/avatar.png'
          " mode="aspectFill"></image>
      </view>
      <view>
        <view>{{ item.name || "" }} {{ item.jobTitle || "" }}</view>
        <view class="color999 fontsize14 marginTop4">{{ item.hospitalName || "" }} {{ item.departmentName || "" }}
        </view>
      </view>
    </view>
    <lack v-if="MyDoctorList.length == 0"></lack>
    <view style="padding-bottom: 20rpx">
      <u-loadmore :status="status" v-if="MyDoctorList.length > 0 && blackFlage" />
    </view>
  </view>
</template>

<script>
import { getMyDoctorList } from '../../api/index.js'
import Lack from "@/chronicDisease/components/lack/lack.vue";

export default {
  components: {
    Lack
  },
  data() {
    return {
      MyDoctorList: [],
      blackFlage: false,
      Doctorquery: {
        pageNumber: 1,//	必选	Integer	页数
        pageSize: 10,//	必选	Integer	每页显示的数量
      },
      status: 'nomore',
      baseUrl: ""
    }
  },
  onLoad() {
    this.MyDoctorList = []
    this.Doctorquery.pageNumber = 1
    this._getMyDoctorList()
    this.baseUrl = this.$store.state.chronic.baseUrl
  },
  onReachBottom() {
    if (this.blackFlage) {
      return;
    }
    this.Doctorquery.pageNumber = this.Doctorquery.pageNumber + 1;
    this._getMyDoctorList()
  },
  methods: {
    //获取医生列表
    _getMyDoctorList() {
      getMyDoctorList(this.Doctorquery).then(res => {
        if (res.data.records.length == 0 && this.Doctorquery.pageNumber != 1) {
          this.blackFlage = true
          return
        }
        this.MyDoctorList = this.MyDoctorList.concat(res.data.records)
      })
    },
    //查看医院详情
    todoctordetail(doctorId) {
      uni.navigateTo({
        url: 'doctor-deatil?doctorId=' + doctorId
      })
    }
  }
}
</script>

<style lang="scss">
.doctor-con {
  padding: 0 40rpx;

  .doctor-list {
    height: 140rpx;
    border-bottom: 2rpx solid #f7f7f7;

    image {
      width: 76rpx;
      height: 76rpx;
      margin-right: 24rpx;
    }
  }
}
</style>